package view.listeners;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;

import javax.swing.JMenuItem;

import view.GuiBuilder;
import view.views.DefaultContentPanelView;
import controller.Controller;

public class ViewMenuMouseListener  extends MouseAdapter {

	

	@Override
	public void mousePressed(MouseEvent e) {

		JMenuItem item = (JMenuItem) e.getSource();

		ArrayList<DefaultContentPanelView> contentViewList = Controller
				.getInstance().getGuiBuilder().getContentViewList();

		for (DefaultContentPanelView panel : contentViewList) {
			if (panel.getName().equals(item.getText())) {

				GuiBuilder guiBuilder = Controller.getInstance()
						.getGuiBuilder();

				guiBuilder.getContentViewPanel().removeAll();
				guiBuilder.getToolBar().clear();
				panel.load();
				guiBuilder.getContentViewPanel().add(panel);
				guiBuilder.getContentViewPanel().revalidate();

				guiBuilder.updateFrame();

			

			}
		}

	}

	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub

	}

}
